package com.apes.fn.scm.crossCompany.transfer.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @BelongsProject: apes-server
 * @BelongsPackage: com.apes.fn.scm.crossCompany.transfer.model
 * @Author: ljp
 * @CreateTime: 2021-06-11 14:01
 * @Description: 可调拨商品配置表
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = TransferProduct.CONST_TABLE_NAME)
public class TransferProduct extends Model {
    public static final String CONST_TABLE_NAME = "transfer_product";
    @Id
    @Column(name = "id",nullable = false,length = 64)
    @Comment("编码")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "可调拨商品配置表", padding = 8)
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "export", referencedColumnName = "id")
    @Comment("调出方")
    private Enumeration export;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "reception", referencedColumnName = "id")
    @Comment("调入方")
    private Enumeration reception;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "supplier_id", referencedColumnName = "id")
    @Comment("供应商范围")
    private PartyRole supplier;

    @Column(name = "maintain",nullable = false,columnDefinition = ApesConst.FIELD_BOOLEAN_TRUE)
    @Comment("可维护标记")
    private boolean maintain = true;

    @Column(name = "valid",nullable = false,columnDefinition = ApesConst.FIELD_BOOLEAN_TRUE)
    @Comment("有效标记")
    private boolean valid = true;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "create_uid", referencedColumnName = "id")
    @Comment("创建人")
    private PartyRole createUid;

    @Column(name = "create_date")
    @Comment("创建日期")
    private Date createDate;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "last_uid", referencedColumnName = "id")
    @Comment("最后更新人")
    private PartyRole lastUid;

}
